<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:62:"D:\GitCode\LayZy/application/admin\view\ad_category_index.html";i:1577721685;s:49:"D:\GitCode\LayZy\application\admin\view\base.html";i:1576323868;}*/ ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>LaySNS后台管理</title>
<link rel="stylesheet" href="/public/plugins/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="/public/css/main.css" media="all" /> 
<link rel="stylesheet" href="/public/css/font.css">
<link rel="stylesheet" href="/public/css/admin.css">
<script src="/public/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="/public/plugins/layui/layui.js"></script>
</head>

<body>

    <!--主体-->
    <div style="margin-bottom:36px;">

        
<div class="admin-main">
    <div class="layui-field-box layui-form">

        <table class="layui-table admin-table">
            <thead>
            <tr>
                <th width="5%" style="text-align: center">ID</th>
                <th width="20%" style="text-align: center">广告位</th>
                <th width="10%" style="text-align: center">一行显示的列数</th>
                <th width="10%" style="text-align: center">行高</th>
                <th width="20%" style="text-align: center">手机版显示</th>
                <th width="20%" style="text-align: center">总开关</th>
                <th width="15%" style="text-align: center">操作</th>
            </tr>
            </thead>
            <tbody>
            <?php if(is_array($list) || $list instanceof \think\Collection || $list instanceof \think\Paginator): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
            <tr>
                <td align="center"><?php echo $vo['id']; ?></td>
                <td align="center"><?php echo $vo['title']; ?></td>
                <td align="center"><?php echo $vo['columns']; ?></td>
                <td align="center"><?php echo $vo['rows']; ?></td>
                <td align="center">
                    <input type="checkbox"  data-column="mobile_open" lay-skin="switch" lay-text="开启|关闭" lay-filter="switchSet" value="<?php echo $vo['id']; ?>" <?php echo $vo[ 'mobile_open']==1 ? 'checked' : ''; ?>>
                </td>
                <td align="center">
                    <input type="checkbox" data-column="status" lay-skin="switch" lay-text="开启|关闭" lay-filter="switchSet" value="<?php echo $vo['id']; ?>" <?php echo $vo[ 'status']==1 ? 'checked' : ''; ?>>
                </td>
                <td align="center">
                    <a class="layui-btn layui-btn-normal layui-btn-sm cate-edit" data-id="<?php echo $vo['id']; ?>" data-name="<?php echo $vo['columns']; ?>"
                       href="javascript:;">修改列数</a>
                    <a class="layui-btn layui-btn-normal layui-btn-sm cate-edit2" data-id="<?php echo $vo['id']; ?>" data-name="<?php echo $vo['rows']; ?>"
                       href="javascript:;">修改行高</a>
                </td>
            </tr>
            <?php endforeach; endif; else: echo "" ;endif; ?>
            </tbody>
        </table>
    </div>


</div>

    </div>

    

    <script>
        var token = '<?php echo $token; ?>';
    </script> 
<script type="text/javascript" src="/public/js/delelement.js"></script>

    <!--页面JS脚本-->
    
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            jq = layui.jquery;


        var accept_ls_push = 0;
        form.on('switch(switchSet)', function(data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            var column=jq(this).data('column');
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "<?php echo url('admin/AdCategory/toggle'); ?>?id=" + data.value + '&status=' + status + '&name='+column;
            jq.get(url, function (data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });

        jq('.cate-edit').on('click', function (data) {

            var id=jq(this).data('id');
            var name=jq(this).data('name');
            var url = "<?php echo url('admin/adCategory/update'); ?>?id=" + id;
            layer.prompt({title: '修改列数(只能填写1,2,3,4,6,12)',value:name}, function(text, index){
                jq.post(url, {columns:text},function (res) {

                    if (res.code == 200) {

                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000
                        },function () {
                            location.reload();
                        });
                    } else {

                        layer.msg(res.msg, {
                            icon: 2,
                            anim: 6,
                            time: 1000
                        });
                    }
                });
            });
            return false;
        });

        jq('.cate-edit2').on('click', function (data) {

            var id=jq(this).data('id');
            var name=jq(this).data('name');
            var url = "<?php echo url('admin/adCategory/update'); ?>?id=" + id;
            layer.prompt({title: '修改广告高度（单位px，最小75）',value:name}, function(text, index){
                jq.post(url, {rows:text},function (res) {

                    if (res.code == 200) {

                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000
                        },function () {
                            location.reload();
                        });
                    } else {

                        layer.msg(res.msg, {
                            icon: 2,
                            anim: 6,
                            time: 1000
                        });
                    }
                });
            });
            return false;
        });
    })
</script>

</body>

</html>